package org.example.Server.controller.survey;

import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.survey.SurveyStuDTO;
import org.example.Server.model.survey.SurveySubmitDTO;
import org.example.Server.service.sruvey.SurveyService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 学生端调查问卷
 */
@RestController
@Slf4j
@RequestMapping("/youxich/survey/stu")
public class StuSurveyController {
    @Autowired
    private SurveyService surveyService;

    /**
     * 获取学生端问卷库调查问卷列表
     *
     * @param user_id
     * @param sem_id
     * @return
     */
    @GetMapping
    public ResultAPI getStuSurveyList(@RequestParam Integer user_id, @RequestParam Integer sem_id, @RequestParam(required = false) Integer status) {
        return surveyService.getStuSurveyList(user_id, sem_id, status);
    }

    /**
     * 获取学生作答详情
     *
     * @param surveyStuDTO
     * @return
     */
    @PostMapping("/detail")
    public ResultAPI getStuSurvey(@RequestBody SurveyStuDTO surveyStuDTO) {
        return surveyService.getStuSurvey(surveyStuDTO);
    }

    /**
     * 学生作答问卷
     *
     * @param surveySubmitDTO
     * @return
     */
    @PostMapping("")
    public ResultAPI addStuSurvey(@RequestBody SurveySubmitDTO surveySubmitDTO) {
        return surveyService.addStuSurvey(surveySubmitDTO);
    }
}
